#include "measure_area.h"

measure_area::measure_area()
{

}
void measure_area::m_area(HObject img,HTuple &In_Area,HTuple &Out_Area)
{
    try
    {
        HObject  ho_Region, ho_ConnectedRegions;
        HObject  ho_Incricle, ho_Region1, ho_ConnectedRegions1, ho_RegionFillUp;
        HObject  ho_OutCricle;




        Threshold(img, &ho_Region, 128, 255);
        Connection(ho_Region, &ho_ConnectedRegions);
        SelectShape(ho_ConnectedRegions, &ho_Incricle, (HTuple("area").Append("circularity")),
			"and", (HTuple(3000).Append(0.8)), (HTuple(100000).Append(1)));
        RegionFeatures(ho_Incricle, "area", &In_Area);

        Threshold(img, &ho_Region1, 0, 128);
        Connection(ho_Region1, &ho_ConnectedRegions1);
        FillUp(ho_ConnectedRegions1, &ho_RegionFillUp);
        SelectShape(ho_RegionFillUp, &ho_OutCricle, (HTuple("area").Append("circularity")),
            "and", (HTuple(50000).Append(0.8)), (HTuple(10000000000).Append(1)));
        RegionFeatures(ho_OutCricle, "area", &Out_Area);
    }
    catch(HException &exception)
    {
        In_Area=0;
        Out_Area=0;
    }


}
